/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 22652
 * Date: 2024-04-01
 * Time: 23:04
 */
public class test_4 {
    public static volatile int dp=0;
    public static  boolean flg=false;
    public static void main(String[] args) throws InterruptedException {
        int n=0;
        Object object=new Object();
        Thread t1 =new Thread(()->{
            while (!flg){
                if (dp==0){
                    System.out.print("A");
                    dp=1;}
            }
        });
        Thread t2 =new Thread(()->{
            while (!flg){
                if (dp==1){
                System.out.print("B");
                dp=2;}
            }
        });

        t1.start();
        t2.start();
        while(n<10){
            if (dp==2){
                System.out.println("C");
                n++;
                if (n!=10) {
                    dp = 0;
                }
            }
        }
        flg=true;
        System.out.println("结束了");
    }
}
